package cn.zn.verify.strategy.impl;

import cn.hutool.core.util.ObjectUtil;
import cn.zn.base.bean.vo.BaseApiVo;
import cn.zn.verify.annotation.Required;
import cn.zn.verify.strategy.VerifyStrategy;

import java.lang.annotation.Annotation;

/**
 * 必填项校验策略
 */
public class RequiredVerifyStrategy<V extends BaseApiVo> implements VerifyStrategy<V> {

    @Override
    public <T extends Annotation> String verify(Object value, V vo, T annotation) {
        if (ObjectUtil.isEmpty(value)) {
            return ((Required) annotation).message();
        }

        return null;
    }
}
